package com.jk.admin.controller;

import com.jk.admin.entity.Order;
import com.jk.admin.entity.User;
import com.jk.admin.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.List;
import java.util.UUID;

@Controller
public class OrderController {

    @Autowired
    private OrderService orderService;

    @RequestMapping("/ordershow")
    public String ordershow(){
        return "order";
    }


    @RequestMapping("/toAddOrderPage")
    public String AddOrder(){
        return "addOrder";
    }

    /* 订单列表  ----------------------- 查询 */
    @RequestMapping("/GetOrderList")
    @ResponseBody
    public List<Order> GetOrderList(Order order,HttpServletRequest request){
        User user1 =(User) request.getSession().getAttribute("user");
        String userid = user1.getUser_id();

        return  orderService.GetOrderList(order, userid);
    }

    /* 订单列表  ----------------------- 删除订单 */
    @RequestMapping("/delOrder")
    public String delOrderId(String[] ids){
        orderService.delOrderId(ids);
        return  null;
    }

    @RequestMapping("/adupPage")
    @ResponseBody
    public void adupPage(String id){
        orderService.adupPage(id);
    }


    /* 订单列表  ----------------------- 新增 */
//    @RequestMapping("/addorder")
//     public void addorder(Order order,HttpServletRequest request){
//        User user1 =(User) request.getSession().getAttribute("user");
//        String userid = user1.getUser_id();
//        order.setUser_id(userid);
//         order.setOrder_id(UUID.randomUUID().toString());
//         order.setOrder_time(new Date().toString());
//         order.setOrder_paystate(5);
//        orderService.addorder(order);
//    }
//
//
//    /* 订单列表  ----------------------- 修改 */
//    @RequestMapping("upadorder")
//    public void upadorder(Order order){
//        orderService.upadorder(order);
//    }
//
//    /* 订单列表  ----------------------- 获取修改id */
//    @RequestMapping("getOrderiD")
//    @ResponseBody
//    public Order getOrderiD(String id){
//       return orderService.getOrderiD(id);
//    }






}
